/*
 * Detect.h
 *
 *  Created on: Jan 25, 2012
 *      Author: Geerten
 */

#ifndef DETECT_H_
#define DETECT_H_

#include <iostream>
#include <stdio.h>
#include <FiducialDetector.h>
#include <pcrctransformation/pcrctransformer.hpp>
#include <pcrctransformation/point2f.hpp>

#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <unicap_cv_bridge.hpp>
#include <CameraCalibration/RectifyImage.h>

using namespace cv;
using namespace unicap_cv_bridge;
using namespace std;
using namespace pcrctransformation;

class Detect {
public:
	Detect(unicap_cv_camera* camera, RectifyImage* ri) {cam = camera; rectifier = ri;}
	bool scan_crate();

	static Mat get_roi(Mat, Point2f, int, int, int);
	static void split_crate(Mat&, Point2f, double);

	void analyse_crate(const Mat&, int, int, int, int);
	void matchTemplate_vision();

	static Mat hsv_hist(Mat, int*, int, int*);
	void draw_hist(Mat&, const Mat&, int);
private:
	Mat final_crate, reference, frameRectified;

	unicap_cv_camera* cam;
	RectifyImage* rectifier;
};

#endif /* DETECT_H_ */
